<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var str = 'abcoefoxyozzopp';
        //先找第一个o所在的位置
        var space = str.indexOf('o');
       
        while (space != -1) {
            console.log('o出现在了索引号为' + space + '的位置');
            space = str.indexOf('o', space + 1);
        }
      
    </script>

</head>

<body>

</body>

</html>